<?php

require_once(dirname(dirname(dirname(__FILE__))).'/appconf.php');


require_once "CMS.class.php";

$local_config = array(
    'this_cgi'       => 'cms/default_cms.php',
    'tmpl'           => array('base_path' => 'cms/default_cms/'), # full path = $this->param('TMPL').$
    'database'       => '',
    'table'          => 'cms_use',
    'cms_auth_group'  => '',
    '#MESSAGE#'      => array(),
);

class cms_default_cms extends CMS{

  function setup(){
    $this->run_modes('search'
                    );
    $this->start_mode('search');
    $this->set_path_info_position(array('id'=>1));
    parent::setup();
  }

  function cgiapp_prerun($rm){
    
    parent::cgiapp_prerun($rm); # login, targeted to run CMS_Login.class.php 
  }
  
  

#no no login

  // search for default login
  function search(){
  	
  	if ($this->header_type() == 'redirect'){
      return '';
    }    

  	
  	echo "logged in",$this->s_param('~CMS_logged-in');
  	
	  $dbh_r = $this->db_connect('read');
	  $default_cms = db_select_one($dbh_r, 'select default_cms from cms_user where id=?', $this->get_cms_userid());
	  
	  if ($default_cms == ''){
	  	//$default_cms = 'cms/builder/mapi/nmplive/news.php';
		  //$default_cms = '/cms/builder/socialmedia/publisher.php';
		  $default_cms = '/cms/builder/hilite/index_carousel.php/';
	  }
	  
	  $default_cms = $this->param('URL').$default_cms;
	  
	  #return $default_cms;
	  return $this->redirect($default_cms);
  }

}//end class

$webapp = new cms_default_cms(
   array('PARAMS' => array_merge($site_global_config, $local_config))
         );
$webapp->run();

/* Custom Helper Function Implementation start here */

?>
